<extend name="Public/index"/>
<block name="pageAddStatic">
    <script src="__JSPLUGINS__/Validform_v5.3.2.js"></script>
</block>
<block name="pageHeader">
    <include file="Public/header.channel" channel="登录"/>
</block>
<block name="pageContent">
    <div class="payment-box">
        <div class="pagem-con">
            <form id="registerform" action="" method="post">
            <ul>
                <li class="xuan">
                    <input type="text" name="mobile" class="input2" placeholder="请输入手机号码" errormsg="手机号码异常！" nullmsg="请输入手机号码！" datatype="m">
                </li>
                <li class="xuan faso">
                    <div><input type="text" name="verify" class="input2 hao" placeholder="请输入验证码" nullmsg="请输入验证码！" datatype="*" tiptype="2"></div>
                    <input class="btn2" value="发送验证码" type="button" onclick="javascript:getVerify(this);">
                </li>
                <li class="xuan">
                    <input type="password" name="password" class="input2" placeholder="登录密码" nullmsg="请输入登录密码！" datatype="*6-18">
                </li>
                <li class="xuan">
                    <input type="password" name="repassword" class="input2" placeholder="请确认密码" nullmsg="请输入登录密码！" datatype="*6-18" recheck="password">
                </li>
                <li class="xuan">
                    <input type="text" name="nickname" class="input2" placeholder="真实姓名" nullmsg="请输入真实姓名！" datatype="s6-30">
                </li>
                <li class="xuan">
                    <input type="text" name="email" class="input2" placeholder="电子邮箱" errormsg="邮箱异常！" nullmsg="请输入邮箱！" datatype="e">
                </li>
                <li class="btn"><a href="javascript:;" onclick="javascript:$('#registerform').submit();">同意以下声明并注册</a></li>
                <li class="xuan banquan"> <a href="#">合作声明</a> <span>已有账号直接<a class="denglu" href="#">登录</a></span> </li>
            </ul>
            </form>
        </div>
    </div>
</block>
<block name="pageJavascript">
    <script>
        $("#registerform").Validform({tiptype:3,showAllError:true});

        var step = 59;      // 倒计时时间
        /**
         * 获取短信验证码
         */
        function getVerify(obj){
            var _this = $(obj);
            var mobile = $.trim($("input[name=mobile]").val()); // 手机号
            console.log(mobile);
            if(mobile==''){
                layer.msg('您的手机号不能为空!');
                return;
            }
            step = 59;
            _this.val('重新发送60');
            // 倒计时功能
            var _res = setInterval(function()
            {
                _this.attr("disabled", true);//设置disabled属性
                _this.val('重新发送'+step);
                step-=1;
                if(step <= 0){
                    _this.removeAttr("disabled"); //移除disabled属性
                    _this.val('发送验证码');
                    clearInterval(_res);//清除setInterval
                }
            },1000);

            // 发送短信请求
            var data = {};
            data['mobile'] = mobile;
            $.ajax({
                url:"{:U('smsVerify')}",
                data:data,
                type:'POST',
                dataType:'json',
                success:function(result){
                    console.log(result);
                    if(result && result.codel==0){
                    }else if(result && result.code!=0){
                        layer.msg(result.msg);
                    }else{
                        layer.msg('获取手机验证码失败!');
                    }
                }
            });
        }
    </script>
</block>
